/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.streamerstudio.model.gstreamer.registry.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EcoreUtil;

import org.gstreamer.ElementFactory;

import org.streamerstudio.model.gstreamer.registry.GstElement;
import org.streamerstudio.model.gstreamer.registry.GstPlugin;
import org.streamerstudio.model.gstreamer.registry.RegistryPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Gst Element</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.streamerstudio.model.gstreamer.registry.impl.GstElementImpl#getPlugin <em>Plugin</em>}</li>
 *   <li>{@link org.streamerstudio.model.gstreamer.registry.impl.GstElementImpl#getAuthor <em>Author</em>}</li>
 *   <li>{@link org.streamerstudio.model.gstreamer.registry.impl.GstElementImpl#getLongName <em>Long Name</em>}</li>
 *   <li>{@link org.streamerstudio.model.gstreamer.registry.impl.GstElementImpl#getGlibClass <em>Glib Class</em>}</li>
 *   <li>{@link org.streamerstudio.model.gstreamer.registry.impl.GstElementImpl#getFactory <em>Factory</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class GstElementImpl extends GstObjectImpl implements GstElement {
	/**
	 * The default value of the '{@link #getAuthor() <em>Author</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAuthor()
	 * @generated
	 * @ordered
	 */
	protected static final String AUTHOR_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getAuthor() <em>Author</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAuthor()
	 * @generated
	 * @ordered
	 */
	protected String author = AUTHOR_EDEFAULT;

	/**
	 * The default value of the '{@link #getLongName() <em>Long Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLongName()
	 * @generated
	 * @ordered
	 */
	protected static final String LONG_NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getLongName() <em>Long Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLongName()
	 * @generated
	 * @ordered
	 */
	protected String longName = LONG_NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getGlibClass() <em>Glib Class</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGlibClass()
	 * @generated
	 * @ordered
	 */
	protected static final String GLIB_CLASS_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getGlibClass() <em>Glib Class</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGlibClass()
	 * @generated
	 * @ordered
	 */
	protected String glibClass = GLIB_CLASS_EDEFAULT;

	/**
	 * The default value of the '{@link #getFactory() <em>Factory</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFactory()
	 * @generated
	 * @ordered
	 */
	protected static final ElementFactory FACTORY_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getFactory() <em>Factory</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFactory()
	 * @generated
	 * @ordered
	 */
	protected ElementFactory factory = FACTORY_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected GstElementImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return RegistryPackage.Literals.GST_ELEMENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public GstPlugin getPlugin() {
		if (eContainerFeatureID() != RegistryPackage.GST_ELEMENT__PLUGIN) return null;
		return (GstPlugin)eContainer();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetPlugin(GstPlugin newPlugin, NotificationChain msgs) {
		msgs = eBasicSetContainer((InternalEObject)newPlugin, RegistryPackage.GST_ELEMENT__PLUGIN, msgs);
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPlugin(GstPlugin newPlugin) {
		if (newPlugin != eInternalContainer() || (eContainerFeatureID() != RegistryPackage.GST_ELEMENT__PLUGIN && newPlugin != null)) {
			if (EcoreUtil.isAncestor(this, newPlugin))
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
			NotificationChain msgs = null;
			if (eInternalContainer() != null)
				msgs = eBasicRemoveFromContainer(msgs);
			if (newPlugin != null)
				msgs = ((InternalEObject)newPlugin).eInverseAdd(this, RegistryPackage.GST_PLUGIN__ELEMENTS, GstPlugin.class, msgs);
			msgs = basicSetPlugin(newPlugin, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, RegistryPackage.GST_ELEMENT__PLUGIN, newPlugin, newPlugin));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getAuthor() {
		return author;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAuthor(String newAuthor) {
		String oldAuthor = author;
		author = newAuthor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, RegistryPackage.GST_ELEMENT__AUTHOR, oldAuthor, author));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getLongName() {
		return longName;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLongName(String newLongName) {
		String oldLongName = longName;
		longName = newLongName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, RegistryPackage.GST_ELEMENT__LONG_NAME, oldLongName, longName));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getGlibClass() {
		return glibClass;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setGlibClass(String newGlibClass) {
		String oldGlibClass = glibClass;
		glibClass = newGlibClass;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, RegistryPackage.GST_ELEMENT__GLIB_CLASS, oldGlibClass, glibClass));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ElementFactory getFactory() {
		return factory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setFactory(ElementFactory newFactory) {
		ElementFactory oldFactory = factory;
		factory = newFactory;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, RegistryPackage.GST_ELEMENT__FACTORY, oldFactory, factory));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case RegistryPackage.GST_ELEMENT__PLUGIN:
				if (eInternalContainer() != null)
					msgs = eBasicRemoveFromContainer(msgs);
				return basicSetPlugin((GstPlugin)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case RegistryPackage.GST_ELEMENT__PLUGIN:
				return basicSetPlugin(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
		switch (eContainerFeatureID()) {
			case RegistryPackage.GST_ELEMENT__PLUGIN:
				return eInternalContainer().eInverseRemove(this, RegistryPackage.GST_PLUGIN__ELEMENTS, GstPlugin.class, msgs);
		}
		return super.eBasicRemoveFromContainerFeature(msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case RegistryPackage.GST_ELEMENT__PLUGIN:
				return getPlugin();
			case RegistryPackage.GST_ELEMENT__AUTHOR:
				return getAuthor();
			case RegistryPackage.GST_ELEMENT__LONG_NAME:
				return getLongName();
			case RegistryPackage.GST_ELEMENT__GLIB_CLASS:
				return getGlibClass();
			case RegistryPackage.GST_ELEMENT__FACTORY:
				return getFactory();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case RegistryPackage.GST_ELEMENT__PLUGIN:
				setPlugin((GstPlugin)newValue);
				return;
			case RegistryPackage.GST_ELEMENT__AUTHOR:
				setAuthor((String)newValue);
				return;
			case RegistryPackage.GST_ELEMENT__LONG_NAME:
				setLongName((String)newValue);
				return;
			case RegistryPackage.GST_ELEMENT__GLIB_CLASS:
				setGlibClass((String)newValue);
				return;
			case RegistryPackage.GST_ELEMENT__FACTORY:
				setFactory((ElementFactory)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case RegistryPackage.GST_ELEMENT__PLUGIN:
				setPlugin((GstPlugin)null);
				return;
			case RegistryPackage.GST_ELEMENT__AUTHOR:
				setAuthor(AUTHOR_EDEFAULT);
				return;
			case RegistryPackage.GST_ELEMENT__LONG_NAME:
				setLongName(LONG_NAME_EDEFAULT);
				return;
			case RegistryPackage.GST_ELEMENT__GLIB_CLASS:
				setGlibClass(GLIB_CLASS_EDEFAULT);
				return;
			case RegistryPackage.GST_ELEMENT__FACTORY:
				setFactory(FACTORY_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case RegistryPackage.GST_ELEMENT__PLUGIN:
				return getPlugin() != null;
			case RegistryPackage.GST_ELEMENT__AUTHOR:
				return AUTHOR_EDEFAULT == null ? author != null : !AUTHOR_EDEFAULT.equals(author);
			case RegistryPackage.GST_ELEMENT__LONG_NAME:
				return LONG_NAME_EDEFAULT == null ? longName != null : !LONG_NAME_EDEFAULT.equals(longName);
			case RegistryPackage.GST_ELEMENT__GLIB_CLASS:
				return GLIB_CLASS_EDEFAULT == null ? glibClass != null : !GLIB_CLASS_EDEFAULT.equals(glibClass);
			case RegistryPackage.GST_ELEMENT__FACTORY:
				return FACTORY_EDEFAULT == null ? factory != null : !FACTORY_EDEFAULT.equals(factory);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (author: ");
		result.append(author);
		result.append(", longName: ");
		result.append(longName);
		result.append(", glibClass: ");
		result.append(glibClass);
		result.append(", factory: ");
		result.append(factory);
		result.append(')');
		return result.toString();
	}

} //GstElementImpl
